const {
  getCourseList
} = require("../../../api/api.js");
const pageMixin = require('../../../mixin/pageMixin.js');
const {
  _navigateTo
} = require("../../../utils/util.js");
Page({
  mixins: [pageMixin],
  /**
   * 页面的初始数据
   */
  data: {
    courseTitle: {
      0: '全部',
      1: '视频',
      2: '音频',
      3: '文章'
    },
    loadMethod: getCourseList,
    allType: ['', 1, 2, 3],
    loadOptions: {
      currentType: '',
      typeKey: 'type'
    },
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    /**
     * 获取轮播数据
     */
    this.loadData();
  },
  onReachBottom() {
    this.bottomLoading().catch((e) => {
      console.log(e)
    })
  },
  /**
   * 点击跳转到指定详情页面
   */
  toanydetail(e) {
    const {
      id,
      type
    } = e.detail;
    console.log(id, type)
    if (type === 1) {
      _navigateTo(`./video-detail/index?id=${id}`)
    } else if (type === 2) {
      _navigateTo(`./audio-detail/index?id=${id}`)
    } else if (type === 3) {
      _navigateTo(`./text-detail/index?id=${id}`)
    }
  }
})